/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.osdtsystem.utils;

import gnu.trove.TIntArrayList;
import java.util.AbstractList;

/**
 *
 * @author mwh
 */
public class TroveIntList extends AbstractList<Integer> implements Trimmable, FastintArrayReturn{

    TIntArrayList list;

    public TroveIntList() {
        list = new TIntArrayList();
    }

    public TroveIntList(int capacity) {
        list = new TIntArrayList(capacity);
    }

    public TroveIntList(int[] array) {
        list = new TIntArrayList(array);
    }

    @Override
    public Integer get(int index) {
        return list.get(index);
    }

    @Override
    public int size() {
        return list.size();
    }

    @Override
    public Integer set(int index, Integer element) {
        int oldvalue = list.get(index);
        list.set(index, element);
        return oldvalue;
    }

    @Override
    public boolean  add(Integer element) {
      list.add(element);
      return true;
    }

    @Override
    public void add(int index, Integer element) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Integer remove(int index) {
        return list.remove(index);
    }

    @Override
    public void trimToSize() {
        list.trimToSize();
    }

    @Override
    public int[] getArray() {
        return list.toNativeArray();
    }
}
